<?php
class stat extends base{

	public function init(){
		parent::init();

		$this->tit = '统计';

		$this->siteObj = D('site');
	}

	/**
     * 数据统计主页
     * @return mixed
     * @throws \think\Exception
     */
    public function index()
    {
		// $this->survey = $this->siteObj->getSurveyData();
		// $this->echarts7days = $this->siteObj->getTransactionTrend();
		// $this->goodsRanking = $this->siteObj->getGoodsRanking();
		// $this->userExpendRanking = $this->siteObj->geUserExpendRanking();

		$this->survey = [
            // 用户数量
            'user_total' => 0,
            // 消费人数
            'consume_users' => 0,
            // 付款订单数
            'order_total' => 0,
            // 付款订单总额
            'order_total_money' => 0,
            // 商品总量
            'goods_total' => 0,
            // 用户充值总额
            'recharge_total' => 0,
        ];
		$this->echarts7days = [
            'date' => [],
            'order_total' => [],
            'order_total_price' => []
        ];
		$this->goodsRanking = [];
		$this->userExpendRanking = [];
    }

    /**
     * 数据概况API
     * @param null $startDate
     * @param null $endDate
     * @return array
     * @throws \think\Exception
     */
    public function survey($startDate = null, $endDate = null)
    {
		// $data = $this->siteObj->getSurveyData($startDate, $endDate);
		$data = [
            // 用户数量
            'user_total' => 0,
            // 消费人数
            'consume_users' => 0,
            // 付款订单数
            'order_total' => 0,
            // 付款订单总额
            'order_total_money' => 0,
            // 商品总量
            'goods_total' => 0,
            // 用户充值总额
            'recharge_total' => 0,
		];
		
		$this->renderSuccess('', '',$data);
		
    }

}